package seGobangResources;
import java.util.*;
import seGobangResources.Exceptions.*;
/**
 *
 * @author plus
 */
public class StringRes {
    public static final int ENGLISH=0, ZHCN=1;
    private static int currentLanguage;
    private static HashMap<Integer,HashMap <String,String>> StringTable=null;

    public static void init() {
        StringTable=new HashMap<Integer,HashMap <String,String>> ();
        HashMap<String,String> EnghishTable=new HashMap<String,String>();
            EnghishTable.put("AppTitle", "SE Gobang");
            EnghishTable.put("Player1", "Player 1");
            EnghishTable.put("Player2", "Player 2");
        StringTable.put(ENGLISH,EnghishTable );
        
        HashMap<String,String> ZHCNTable=new HashMap<String,String>();
            ZHCNTable.put("AppTitle", "思弈五子棋");
            ZHCNTable.put("Player1", "玩家1");
            ZHCNTable.put("Player2", "玩家2");
        StringTable.put(ZHCN,ZHCNTable );
    }
    
    public static int languageChangeTo(int LanguageID){
        if(StringTable==null) init();
        currentLanguage=LanguageID;
        return currentLanguage;
    }
    
    public static String getString(String Key)throws Exception{
        if(StringTable==null) init();
        HashMap <String,String> LanguageMap=StringTable.get(currentLanguage);
        String res=LanguageMap.get(Key);
        if (res==null){
            throw new StringNotExistException();
        }
        return res;
    }
}
